<template>
  <el-dialog
    @close="cancel"
    :title="title"
    :visible.sync="open"
    width="660px"
    class="dialogClass"
    append-to-body
  >
    <template slot="title">
      <div class="modalTitle">
        <img src="@/assets/bluelogo/drawerTitle.png" alt class="titleLogo" />
        {{ title }}
      </div>
    </template>
    <div class="modalCard">
      <div class="titlefangkuai">
        <div class="fangkuai"></div>
        <div class="Header">陈案基本信息</div>
      </div>
      <el-descriptions
        class="descriptions"
        label-width="120px"
        :column="2"
        size="medium"
        labelClassName="label"
        contentClassName="content"
      >
        <el-descriptions-item label="年份">{{ formData.trendYear }}年</el-descriptions-item>
        <el-descriptions-item label="案件名称">{{ formData.caseName }}</el-descriptions-item>
        <el-descriptions-item label="立案时间">{{ formData.filingTime }}</el-descriptions-item>
        <el-descriptions-item label="案件阶段">
          <dict-tag :options="dict.type.case_stage" :value="formData.caseStatus" />
        </el-descriptions-item>
        <el-descriptions-item label="完成状态">
          <dict-tag :options="dict.type.comple_status" :value="formData.compleStatus" />
        </el-descriptions-item>
      </el-descriptions>
      <el-divider></el-divider>
      <div class="modalCard">
        <div class="titlefangkuai">
          <div class="fangkuai"></div>
          <div class="Header">陈案详细信息</div>
        </div>
          <el-descriptions
            class="descriptions"
            label-width="120px"
            :column="1"
            size="medium"
            labelClassName="label"
            contentClassName="content"
          >
            <el-descriptions-item label="陈案详情">{{ formData.caseDetails }}</el-descriptions-item>
          </el-descriptions>
      </div>
    </div>
    <div slot="footer">
      <div class="dialog-footer">
        <el-button @click="cancel" class="resetButton" style="margin-right:40px">关闭</el-button>
      </div>
    </div>
  </el-dialog>
</template>
<script>
import { onlyNumber } from "@/utils/commonMethods";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";

import {
  listChen,
  getChen,
  delChen,
  addChen,
  updateChen,
} from "@/api/caseManage/caseChen/chen";
export default {
  dicts: ["case_stage", "comple_status"],
  inheritAttrs: false,
  components: { Treeselect },
  props: {
    detailId: {
      type: Number,
      require: true,
    },
  },
  data() {
    return {
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      formData: {
        id: null,
        trendYear: null,
        caseName: null,
        filingTime: null,
        caseStatus: null,
        caseDetails: null,
        compleStatus: "0",
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        isDelect: null,
      },
    };
  },
  computed: {},
  watch: {
    detailId: {
      handler(value) {
        if (value) {
          this.reset();
          if (value) {
            getChen(value).then((response) => {
              this.formData = response.data;
              this.open = true;
              this.title = "案件详情";
            });
          }
          console.log(this.formData)
          console.log(value);
        }
      },
      immediate: true,
    },
  },
  created() {
  },
  mounted() {},
  methods: {
    onlyNumber,
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.id, //自定义id
        label: node.label, //自定义label
        //处理children，当children为[]或null时，子节点会展示No sub-options，一般子节点不需要展示这个，所以将children置为0
        children: node.children && node.children.length > 0 ? node.children : 0,
      };
    },
    // 取消按钮
    cancel() {
      this.$emit("update:detailId", 0);
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.formData = {
        id: "",
        trendYear: "",
        caseName: "",
        filingTime: "",
        caseStatus: "",
        caseDetails: "",
        compleStatus: "",
        createBy: "",
        createTime: "",
        updateBy: "",
        updateTime: "",
        isDelect: "",
      };
      this.resetForm("form");
    },
  },
};
</script>
<style lang="scss" scoped>
@import "../../../../assets/styles/dialog.scss"; //模态框样式

::v-deep .label {
  width: 120px;
  font-size: 14px;
  font-family: Microsoft YaHei;
  font-weight: 700;
  color: #5e5f61;
  display: inline-block;
  text-align: right;
}
::v-deep .content {
  font-size: 14px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #aeafb0;
}
::v-deep .el-descriptions-item__container {
  margin-bottom: 15px;
}
</style>
